'use strict';

var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');
Object.defineProperty(exports, '__esModule', {
  value: true,
});
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require('@babel/runtime/helpers/objectSpread2'));
var _objectWithoutProperties2 = _interopRequireDefault(
  require('@babel/runtime/helpers/objectWithoutProperties'),
);
var _react = _interopRequireDefault(require('react'));
var _antd = require('antd');
var _FormContext = require('../contexts/FormContext');
var _FormAttrsContext = require('../contexts/FormAttrsContext');
var _FormItem = _interopRequireDefault(require('../FormItem'));
var _consts = require('../consts');
require('./index.css');
var _excluded = ['form', 'children', 'detail'];
/**
 * 基础表单容器，扩展详情展示功能
 * @param props FormProps
 * @returns
 */
var BaseForm = function BaseForm(props) {
  var form = props.form,
    children = props.children,
    detail = props.detail,
    rest = (0, _objectWithoutProperties2.default)(props, _excluded);
  return /*#__PURE__*/ _react.default.createElement(
    'div',
    {
      className: detail ? ''.concat(_consts.ClsPrefix, '-form-detail') : undefined,
    },
    /*#__PURE__*/ _react.default.createElement(
      _antd.Form,
      (0, _objectSpread2.default)(
        {
          form: form,
        },
        rest,
      ),
      /*#__PURE__*/ _react.default.createElement(
        _FormContext.FormContextProvider,
        {
          value: form,
        },
        /*#__PURE__*/ _react.default.createElement(
          _FormAttrsContext.FormAttrsContextProvider,
          {
            value: (0, _objectSpread2.default)(
              {
                detail: detail,
              },
              rest,
            ),
          },
          children,
        ),
      ),
    ),
  );
};
BaseForm.List = _antd.Form.List;
BaseForm.Item = _FormItem.default;
BaseForm.useForm = _antd.Form.useForm;
var _default = BaseForm;
exports.default = _default;
